<template>
	<view class="container">
		<section class="recent-collection">
			<h2>
				<u-icon name="star-fill" size="25" color="#ff6404" style="margin-right: 10rpx;"></u-icon>
				最近收藏
			</h2>
		</section>
		<dynamicList :list="list" ref="dynamicListClick" :initial-value.sync="list" />
		<view class="" style="margin-top: 200rpx;">
			<u-empty  v-if="list.length == 0" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png">
		   </u-empty>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: '全部分类',
				postsAllText: [],
				collections: [ 
				],
				page: 1,
				limit: 10,
				noMoreData: false, // 是否还有更多数据
				loading: false, // 加载状态
				status: 'more',
				list:[]
			};
		},
		mounted() {
		 
		},
		onLoad() {
			 
			this.dynamicsfollow()
		},
		methods: {
			 
			toggleLove(item) {
				item.is_like = item.is_like === 2 ? 1 : 2;
				item.num_like += item.is_like === 2 ? 1 : -1; // 更新喜欢数量
			},
			gotoOpusDetail(item) {
				console.log("idList", item.id);
				uni.navigateTo({
					url: '/pages/home/opusDetail/opusDetail?id=' + item.id
				});
			},
			// 监听触底
			onReachBottom() {
				// 检查是否正在加载和是否还有更多数据
				if (this.status === 'more') {
					this.dynamicsfollow(); // 获取下一页数据
				}
			},
			dynamicsfollow(){
				this.status = 'loading'; // 设置加载状态为 loading
				this.$api.getDynamicCollectionList({
				page: this.page,
				limit: this.limit,
				}).then(res=>{
					if (res.data && res.data.length < 1) {
						this.status = 'noMore'; // 标记没有更多数据
					} else {
						let resList = res.data; // 获取实际数据
						this.list = this.list.concat(resList); // 合并新数据
						this.status = 'more'; // 重置状态为 more
						this.page += 1; // 增加页码
					}
				})
			}
		},
	};
</script>

<style lang="scss">
	page{
		background-color: #f7f7f7;
	}

	.container {
		width: 100%;
		margin: auto;
	}

	.recent-collection h2 {
		margin: 30rpx;
		font-size: 20px;
		color: #333;
		font-weight: 500;
		display: flex;
	}

	.flex-container {
		display: flex;
		line-height: 46rpx;
	}

	.avatar {
		width: 90rpx;
		height: 90rpx;
		border-radius: 50%;
		margin-right: 30rpx;
	}

	.info {
		display: flex;
		flex-direction: column;
	}

	.name {
		color: #000;
		font-weight: 550;
		font-size: 30rpx;
		margin-right: 10rpx;
	}

	.age,
	.time-ago {
		font-size: 24rpx;
		color: #6d6d6d;
	}

	.content {
		margin: 20rpx 0;
		font-weight: 550;
	}

	.collection-item {
		background-color: #fff;
		border-radius: 30rpx;
		box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
		margin-bottom: 20rpx;
		padding: 20rpx;
	}

	.collection-item video {
		width: 100%;
		height: 500rpx;
		margin-top: 20rpx;
		border-radius: 13rpx;
	}

	.functionalStyle {
		display: flex;
		justify-content: space-between;
	}

	.icontype {
		display: flex;
		align-items: center;
		width: 95rpx;
	}

	.custom-icon {
		color: red;
		/* 样式颜色 */
	}

	/* 响应式设计 */
	@media (max-width: 768px) {
		.category-list li {
			flex: 1 0 48%;
			/* 在小屏幕上，每行显示两个分类 */
		}
	}
	
	.functionalStyle {
		display: flex;
	}
</style>